package com.hzqy.web.ac;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.service.hqjc.MultirateServiceBean;
import com.hzqy.web.login.SessionKey;
import com.hzqy.web.vo.CmContentVo;
import com.hzqy.web.vo.CmRecommendVo;

@Controller
@RequestMapping("/multirate")
public class MultirateAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private MultirateServiceBean multirateServiceBean;
	
	/**
	 * 取某个目录下的内容总量
	 * @param f_catalog_id
	 * @param f_cp_cprid 图片类型0缩略图，1剧照，2海报，3图标，4标题图，可同时取多个图片
	 * @param f_cc_definitionflag 转码分辨率  1:720x576 10:1280x720 100:1920x1080 如果多个则相加
	 * @return
	 */
	@RequestMapping("/catalog_count")
	@ResponseBody
	public Object catalog_count(HttpSession session,int f_catalog_id,String f_cp_cprid,int f_cc_definitionflag) {
		String f_sa_id = String.valueOf(session.getAttribute(SessionKey.SESSION_AREA));
		int count= multirateServiceBean.selectContentCount(f_catalog_id,f_cp_cprid,f_cc_definitionflag,f_sa_id,null);
		Map<String, Integer> map=new HashMap<String, Integer>();
		map.put("count", count);
		return map;
	}
	
	/**
	 * 取某个目录下的内容列表
	 * @param f_catalog_id
	 * @param pageNo
	 * @param pageSize
	 * @param f_cp_cprid 图片类型0缩略图，1剧照，2海报，3图标，4标题图，可同时取多个图片
	 * @param f_cc_definitionflag 转码分辨率  1:720x576 10:1280x720 100:1920x1080 如果多个则相加
	 * @return
	 */
	@RequestMapping("/catalog")
	@ResponseBody
	public Object catalog(HttpSession session,int f_catalog_id,int pageNo,int pageSize,String f_cp_cprid,int f_cc_definitionflag) {
		String f_sa_id = String.valueOf(session.getAttribute(SessionKey.SESSION_AREA));
		List<CmContentVo> contentList= multirateServiceBean.selectContentList(f_catalog_id,pageNo,pageSize,f_cp_cprid,f_cc_definitionflag,f_sa_id,null);
		return contentList;
	}
	
	/**
	 * 获取内容媒资信息
	 * @param f_cc_id
	 * @return
	 */
	@RequestMapping("/content")
	@ResponseBody
	public Object content(int f_cc_id,int f_cp_cprid) {
		CmContentVo content= multirateServiceBean.selectContent(f_cc_id,f_cp_cprid);
		return content;
	}
	
	/**
	 * 电影类的取内容影片,如抢鲜看等
	 * @param f_multirate_id
	 * @return
	 */
	@RequestMapping("/content_mov")
	@ResponseBody
	public Object content_mov(int f_cc_multirateid) {
		HashMap<String,HashMap<String,List<CmContentVo>>> content = multirateServiceBean.selectContentMovie(f_cc_multirateid);
		return content;
	}
	
	/**
	 * 获取电视剧的内容影片，如热剧等<br/>
	 * 此方法要升级改造，将返回CmContentVo对象，变更为CmSeriesVo
	 * @param f_multirate_id
	 * @return
	 */
	@RequestMapping("/content_series")
	@ResponseBody
	public Object content_series(int f_cc_multirateid) {
		HashMap<String,HashMap<String,List<CmContentVo>>> content = multirateServiceBean.selectContentSeries(f_cc_multirateid);
		return content;
	}
	
	/**
	 * 根据剧头code拿到包id，epg最新上线、电影跳转详情页只能传剧头code
	 * @param f_cc_code
	 * @return
	 */
	@RequestMapping("/selectMultirateIDByCode")
	@ResponseBody
	public Object selectMultirateIDByCode(String f_cc_code) {
		int f_multirate_id= multirateServiceBean.selectMultirateIDByCode(f_cc_code);
		Map<String, Integer> map=new HashMap<String, Integer>();
		map.put("f_multirate_id", f_multirate_id);
		return map;
	}
}
